<template>
  <div class="info-content info-content-wiki" @click="toDetail(wikiInfo.wikiId)">
    <div class="content-main">
      <div class="content-left">
        <img class="wiki-logo" :src="wikiImage" alt="" />
      </div>
      <div class="content-right">
        <div class="wiki-title">{{ wikiInfo.wikiTitle }}</div>
        <div class="wiki-content">{{removeLabel(wikiInfo.wikiContent)}}</div>
      </div>
    </div>
  </div>
</template>

<script>
/** util */
import { removeLabel } from '@src/util/format/string.ts'
import { PageRoutesTypeEnum } from 'pub-bbx-global/pageType/dist/enum/PageRoutesEnum'
import { openAccurateTab } from '@src/util/platform'
import { getOssUrl } from '@src/util/assets'
const wikiImage = getOssUrl('/im/wiki.png')
export default {
  name: 'wiki-message',
  props: {
    wikiInfo: {
      type: Object,
      default: () => ({}),
    }
  },
  data() {
    return {
      wikiImage
    };
  },
  methods: {
    removeLabel,
    toDetail(id) {
      // 新页面打开详情
      let fromId = window.frameElement.getAttribute('id');
      // this.$platform.openTab({
      //   id: `document_detail_${id}`,
      //   title: '知识库列表',
      //   url: `/wiki/detail/page?wikiId=${id}`,
      //   reload: true,
      //   close: true,
      //   fromId,
      // });
      openAccurateTab({
        type: PageRoutesTypeEnum.PageWikiDetail,
        key: id,
        params: `wikiId=${id}`,
        reload: true,
        fromId
      })
    },
  },
};
</script>

<style scoped lang='scss'>
.info-content {
  cursor: pointer;
}
.info-content-wiki {
  border: 0;
  width: 320px;
  .content-main {
    width: 100%;
    display: flex;
    position: relative;
  }
  .content-left {
    margin-right: 12px;
    .wiki-logo{
      width: 40px;
      height: 40px;
      border-radius: 4px;
    }
  }
  .content-right {
    flex: 1;
    width: 226px;
    .wiki-title {
      font-size: 14px;
      color: #595959;
      font-weight: bold;
      margin-bottom: 4px;
      @include text-ellipsis();
    }
    .wiki-content {
      font-size: 12px;
      color: #8c8c8c;
      @include text-ellipsis-2();
    }
  }
}
</style>